<template>
    <div>
        <el-dialog title="添加" :visible.sync="dialogFormVisible">
            <el-form :model="form">
                <el-form-item label="名称" :label-width="formLabelWidth">
                    <el-input v-model="form.name" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="描述" :label-width="formLabelWidth">
                    <el-input v-model="form.description" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="启用状态" :label-width="formLabelWidth">
                    <el-select v-model="form.type" placeholder="请选择">
                        <el-option label="启用" :value=true></el-option>
                        <el-option label="停用" :value=false></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="addhandler">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
export default {
    // props: {
    //     value: {
    //         type: Boolean,
    //         default: false
    //     }
    // },
    // computed: {
    //     dialogFormVisible: {
    //         get () {
    //             return this.value
    //         },
    //         set (v) {
    //             this.$emit('input', v)
    //         }
    //     }
    // },
    data() {
        return {
            // dialogFormVisible:false,
            form: {
                name: '',
                description: '',
                type: true
            },
            formLabelWidth: '',
            dialogFormVisible: false

        };
    },
    props: {
        requestUrl: {
            type: String,
            default: ''
        },
        currentTab: {
            type: String,
            default: ''
        }
    },
    methods: {
        show() {
            this.dialogFormVisible = true
        },
        addhandler() {
            this.dialogFormVisible = false
            this.$axios({
                url: `${this.requestUrl}${this.currentTab}`,
                method: 'post',
                data: {
                    name: this.form.name,
                    description: this.form.description,
                    type: this.form.type
                }
            }),
                // this.form = {},
            this.$emit('addSuccess')
        }
    }


}
</script>